package com.crk.controller;


import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.crk.entity.Patient;
import com.crk.service.IPatientService;
import com.crk.util.RestResult;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author com.crk
 * @since 2021-03-29
 */
@CrossOrigin
@RestController
@RequestMapping("/patient")
public class PatientController {

	@Autowired
	private IPatientService patService;
	
	@RequestMapping("/getPats")
	public RestResult<Patient> getPatients(){
		List<Patient> list = patService.list();
		return RestResult.ok(list);
	}
	
	@RequestMapping("/addPat")
	public RestResult<Patient> addPatient(Patient pat){
		patService.save(pat);
		return new RestResult<>();
	}
	
	@RequestMapping("/updatePat")
	public RestResult<Patient> updatePatient(Patient pat){
		patService.updateById(pat);
		return new RestResult<>();
	}
	
	
	@RequestMapping("/deletePat")
	public RestResult<Patient> deletePatient(Integer patIds){
		patService.removeByIds(Arrays.asList(patIds));
		return new RestResult<>();
	}
}

